<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Authenticate without domain part in email address</title>
        <link rel="stylesheet" type="text/css" href="./css/markdown.css" />
    </head>
    <body>

    <div id="navigation">
    <a href="https://www.iredmail.org" target="_blank">
        <img alt="iRedMail web site"
             src="./images/logo-iredmail.png"
             style="vertical-align: middle; height: 30px;"
             />&nbsp;
        <span>iRedMail</span>
    </a>
    &nbsp;&nbsp;//&nbsp;&nbsp;<a href="./index.html">Document Index</a></div><h1 id="authenticate-without-domain-part-in-email-address">Authenticate without domain part in email address</h1>
<div class="admonition attention">
<p class="admonition-title">Attention</p>
<p>Check out the lightweight on-premises email archiving software developed by iRedMail team: <a href="https://spiderd.io/">Spider Email Archiver</a>.</p>
</div>
<div class="toc">
<ul>
<li><a href="#authenticate-without-domain-part-in-email-address">Authenticate without domain part in email address</a><ul>
<li><a href="#dovecot">Dovecot</a></li>
<li><a href="#roundcube-webmail">Roundcube Webmail</a></li>
</ul>
</li>
</ul>
</div>
<p>With default settings, client must use full email address as username for
POP3/IMAP/SMTP/webmail login, if you want to login without domain name part in
email address, please follow below steps.</p>
<h2 id="dovecot">Dovecot</h2>
<p>Open Dovecot config file <code>/etc/dovecot/dovecot.conf</code> (Linux/OpenBSD) or
<code>/usr/local/etc/dovecot/dovecot.conf</code> (FreeBSD), find parameter
<code>auth_default_realm</code>, set the domain name you want to allow user to login
without domain name part in email address. For example:</p>
<pre><code>auth_default_realm = mydomain.com
</code></pre>
<p>Restarting Dovecot is required. After restarted Dovecot, user logins as
<code>john.smith</code> will be rewritten to <code>john.smith@mydomain.com</code> by Dovecot.
This works for POP3/IMAP/SMTP services.</p>
<h2 id="roundcube-webmail">Roundcube Webmail</h2>
<p>Open Roundcube webmail
<a href="./file.locations.html#roundcube-webmail">config file <code>config/main.inc.php</code></a>,
find parameter <code>$config['username_domain']</code>, list your domain name
in this parameter. For example:</p>
<pre><code>// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' =&gt; 'domain' values to support multiple hosts
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['username_domain'] = 'mydomain.com';
</code></pre>
<p>Restarting web server (Apache or php-fpm) is recommended.</p><div class="footer">
    <p style="text-align: center; color: grey;">All documents are available in <a href="https://github.com/iredmail/docs/">GitHub repository</a>, and published under <a href="http://creativecommons.org/licenses/by-nd/3.0/us/" target="_blank">Creative Commons</a> license. You can <a href="https://github.com/iredmail/docs/archive/master.zip">download the latest version</a> for offline reading. If you found something wrong, please do <a href="https://www.iredmail.org/contact.html">contact us</a> to fix it.</p>
</div></body></html>